//
//  SortVC.m
//  NewNest
//
//  Created by hesiyao on 16/1/15.
//  Copyright © 2016年 www.lanou3g.com蓝鸥科技. All rights reserved.
//

#import "SortVC.h"
#import "SortView.h"
#import "SubjectVC.h"
#import "BeautyPictureVC.h"
#import "ActivityVC.h"
#import "DecoratingVC.h"
@interface SortVC ()
@property (nonatomic, retain) SortView *subjectView;
@property (nonatomic, retain) SortView *decoratingView;
@property (nonatomic, retain) SortView *beautyPictureView;
@property (nonatomic, retain) SortView *activityView;
@end

@implementation SortVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //navigation
    self.navigationItem.title = @"分类";
    
    // 创建视图
    [self createSubviews];
}

/// 创建视图方法
- (void)createSubviews
{
    // 专题
    self.subjectView = [[SortView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, (self.view.frame.size.height - 64 - 49) / 4)];
    [self.view addSubview:_subjectView];
    _subjectView.sortLabel.text = @"专题";
    _subjectView.backImg.image = [UIImage imageNamed:@"backImg1.jpg"];
    //开启用户交互
    _subjectView.userInteractionEnabled = YES;
    UITapGestureRecognizer *SubjectTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(subjectAction:)];
    [_subjectView addGestureRecognizer:SubjectTap];
    [SubjectTap release];
    [self.view addSubview:_subjectView];
    [_subjectView release];
    // 正在装修
    self.decoratingView = [[SortView alloc] initWithFrame:CGRectMake(0, _subjectView.frame.origin.y + _subjectView.frame.size.height, self.view.frame.size.width, _subjectView.frame.size.height)];
    [self.view addSubview:_decoratingView];
    _decoratingView.sortLabel.text = @"正在专修";
    _decoratingView.backImg.image = [UIImage imageNamed:@"backImg2.jpg"];
    //开启用户交互
    _decoratingView.userInteractionEnabled = YES;
    // 添加轻拍手势
    UITapGestureRecognizer *decoratingTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(decoratingAction:)];
    [_decoratingView addGestureRecognizer:decoratingTap];
    [decoratingTap release];
    
    [self.view addSubview:_decoratingView];
    [_decoratingView release];
    
    // 美图部分
    self.beautyPictureView = [[SortView alloc] initWithFrame:CGRectMake(0, _decoratingView.frame.origin.y + _subjectView.frame.size.height, self.view.frame.size.width, _decoratingView.frame.size.height)];
    [self.view addSubview:_beautyPictureView];
    _beautyPictureView.sortLabel.text = @"美图";
    _beautyPictureView.backImg.image = [UIImage imageNamed:@"backImg5.jpg"];
    //开启用户交互
    _beautyPictureView.userInteractionEnabled = YES;
    // 添加轻拍手势
    UITapGestureRecognizer *beautyPictureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(beautyPictureAction:)];
    [_beautyPictureView addGestureRecognizer:beautyPictureTap];
    [beautyPictureTap release];
    [self.view addSubview:_beautyPictureView];
    [_beautyPictureView release];
    
    // 优选活动
    self.activityView = [[SortView alloc] initWithFrame:CGRectMake(0, _beautyPictureView.frame.origin.y + _subjectView.frame.size.height, self.view.frame.size.width, _beautyPictureView.frame.size.height)];
    [self.view addSubview:_activityView];
    _activityView.sortLabel.text = @"优选活动";
    _activityView.backImg.image = [UIImage imageNamed:@"backImg7.jpg"];
    //开启用户交互
    _activityView.userInteractionEnabled = YES;
    // 添加轻拍手势
    UITapGestureRecognizer *activityTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(activityAction:)];
    [_activityView addGestureRecognizer:activityTap];
    [activityTap release];
    [self.view addSubview:_activityView];
    [_activityView release];
    
}

/// 实现Subject轻拍方法实现
- (void)subjectAction:(UITapGestureRecognizer *)tap
{
    SubjectVC *subjectVC = [[SubjectVC alloc] init];
    [self.navigationController pushViewController:subjectVC animated:YES];
}

/// 实现BeautyPicture轻拍方法实现
- (void)beautyPictureAction:(UITapGestureRecognizer *)tap
{
    BeautyPictureVC *beautyVC = [[BeautyPictureVC alloc] init];
    [self.navigationController pushViewController:beautyVC animated:YES];
}

/// 实现activityAction的轻拍方法
- (void)activityAction:(UITapGestureRecognizer *)tap
{
    ActivityVC *activityVC = [[ActivityVC alloc] init];
    [self.navigationController pushViewController:activityVC animated:YES];
}

/// 实现decoratingAction的轻拍方法
- (void)decoratingAction:(UITapGestureRecognizer *)tap
{
    DecoratingVC *decoratingVC = [[DecoratingVC alloc] init];
    [self.navigationController pushViewController:decoratingVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
